#! /bin/sh
# shell script to run TRIP and TRAP tests and create diffs.
#
#   Copyright (C) 2010-2014 Peter Breitenlohner <tex-live@tug.org>
#
#   This file is free software; the copyright holder
#   gives unlimited permission to copy and/or distribute it,
#   with or without modifications, as long as this notice is preserved.
#
# Due to filename conflicts, these tests must be run sequentially.

me=`basename $0`

tmp=$me.$$

trap "rm -f $tmp" 1 2 13 15

echo "$me: Running TRIP and TRAP tests and creating diffs."
rc=0
for file
do
  case $file in
  trip.diffs) tst=triptest; msg='TRIP test for TeX';;
  mftrap.diffs) tst=mftraptest; msg='TRAP test for Metafont';;
  mptrap.diffs) tst=mplibdir/mptraptest; msg='MPTRAP test for MetaPost';;
  etrip.diffs) tst=etexdir/etriptest; msg='e-TRIP test for e-TeX';;
  ptrip.diffs) tst=ptexdir/ptriptest; msg='TRIP test for pTeX';;
  eptrip.diffs) tst=eptexdir/eptriptest; msg='e-TRIP test for e-pTeX';;
  uptrip.diffs) tst=uptexdir/uptriptest; msg='TRIP test for upTeX';;
  euptrip.diffs) tst=euptexdir/euptriptest; msg='e-TRIP test for e-upTeX';;
  *) echo "$me: Bad argument \`$file'"; exit 1;;
  esac
  echo ">>> Running $msg."
  is_OK=:
  $MAKE TESTS=$tst check-am >$tmp 2>&1 \
    && grep "PASS: $tst" $tmp >/dev/null 2>&1 \
    || { echo "FAIL: $tst"; is_OK=false; }
  sed -e "s%$abs_srcdir/%SRCDIR/%" \
      -e "s%\.\./%./%" \
      $tst.log >$file
  $is_OK && {
    echo "PASS: $tst" >>$file
    echo "PASS: $tst"
  } || {
    echo "FAIL: $tst" >>$file
    rc=1
  }
  rm -f $tmp
done
echo "$me: All done"
exit $rc


